<template>
  <div class="re-main chart-full">
    <header-bar></header-bar>
    <div class="chart-full" style="display: flex; height: calc(100% - 64px); overflow-y: hidden">
      <menu-panel :menuList="menuList" v-on:choose-menu="chooseMenu"></menu-panel>
      <div style="position: relative; height: 100%; width: calc(100% - 200px)">
        <!-- <page-frame class="chart-full"></page-frame> -->
        <schema-inspector
          v-if="metaStoreObj"
          :metaStoreObj="metaStoreObj"
          :schemaId="schemaId"
          @refresh-demo-view="refreshDemoView"
        >
          <Button size="small" class="top-btn last-btn" title="配置">配置</Button>
        </schema-inspector>
      </div>
    </div>
  </div>
</template>

<script>
import HeaderBar from '../components/HeaderBar';
import MenuPanel from '../components/MenuPanel';
import SchemaInspector from '../designer-main/SchemaInspector.vue';

const instListMap = [];
const instSelectMap = {};

const files = require.context('./frontpage', true, /\.json$/);
files.keys().forEach(key => {
  const jsonObj = files(key);
  const tmpName = jsonObj.name;
  instSelectMap[tmpName] = jsonObj;
  instListMap.push({
    id: jsonObj.name,
    name: jsonObj.title,
    content: jsonObj,
  });
});

export default {
  name: 'PageOuter',
  components: { HeaderBar, MenuPanel, SchemaInspector },
  data() {
    return {
      menuList: [
        {
          id: '1',
          name: '应用分析',
          subList: instListMap,
        },
      ],
      metaStoreObj: null,
      schemaId: 'frontpage',
    };
  },
  methods: {
    refreshDemoView() {
      debugger;
    },
    chooseMenu(paramObj) {
      this.metaStoreObj = paramObj.content;
    },
    initFrame(pid) {
      let menuObj = this.menuList[0].subList[0];
      if (pid !== 'default') {
        menuObj =
          this.menuList[0].subList.find(item => {
            return item.id === pid;
          }) || this.menuList[0].subList[0];
      }

      this.chooseMenu(menuObj);
    },
  },

  mounted() {
    // this.initFrame(this.$route.params.id);
  },
};
</script>

<style scoped>
</style>
